<script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>

<h1>PDF.js 'Hello, world!' example</h1>
<script>
    // If absolute URL from the remote server is provided, configure the CORS
// header on that server.
var url = 'https://sf0-sign-boe.bytedance.net/tos-boe-i-wmbblkuhlo/9eee6f8c0cd54251883174a30db75c13?x-expires=1635841081&x-signature=hnka92jI5KSPwjRO0ja6ZmSNWI4%3D';

// Loaded via <script> tag, create shortcut to access PDF.js exports.
var pdfjsLib = window['pdfjs-dist/build/pdf'];

// The workerSrc property shall be specified.
pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';

// Asynchronous download of PDF
var loadingTask = pdfjsLib.getDocument(url);
loadingTask.promise.then(function(pdf) {
  console.log('PDF loaded');
  var pdfDoc = null;

function createPage() {
    var div = document.createElement("canvas");
    document.body.appendChild(div);
    return div;
}

function renderPage(num) {
  var pageNumber = num;
  pdf.getPage(pageNumber).then(function(page) {
    console.log('Page loaded');
    var scale = 2;
    var viewport = page.getViewport({scale: scale});
  
    // Prepare canvas using PDF page dimensions
    var canvas = createPage();
    var context = canvas.getContext('2d');
    canvas.height = viewport.height;
    canvas.width = viewport.width;
  
    // Render PDF page into canvas context
    var renderContext = {
      canvasContext: context,
      viewport: viewport
    };
    var renderTask = page.render(renderContext);
    renderTask.promise.then(function () {
      console.log('Page rendered');
    });
  });
}

    pdfDoc = pdf;
    for (var i = 1; i <= pdfDoc.numPages; i++) {
        renderPage(i)
    }
 // Fetch the first page

}, function (reason) {
  // PDF loading error
  console.error(reason);
});
</script>